package com.timesheet.server.core.emf;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class EMF {

	private static final String PERSISTENCE_UNIT_NAME = "timesheet";

	private static EntityManagerFactory factory;

	private static EntityManager em;

	public static EntityManager getEntityManager() {

		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
		if (em == null) {
			em = factory.createEntityManager();
			return em;
		}
		return em;
	}

}